package com.thread;

import com.DemoApplication;
import com.thread.task.MyTask;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import javax.annotation.Resource;
import java.util.concurrent.CountDownLatch;

/**
 * @Auther: zwg
 * @Date: 2019/2/15 11:06
 * @Description:
 */
@RunWith(SpringRunner.class)
@SpringBootTest(classes = DemoApplication.class)
public class Test {

    @Resource(name = "myTask")
    private MyTask myTask;

    @org.junit.Test
    public void test1(){
        final CountDownLatch  countDownLatch = new CountDownLatch(4);
        try {
            myTask.method1(countDownLatch);
            myTask.method2(countDownLatch);
            myTask.method3(countDownLatch);
            myTask.method4(countDownLatch);
            countDownLatch.await();
            System.out.println("我是主线程");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        String s = new String("1");
        s.intern();
        String s2 = "1";
        System.out.println(s == s2);

        String s3 = new String("1") + new String("1");
        s3.intern();
        String s4 = "11";
        System.out.println(s3 == s4);
    }

}
